var express = require('express');
var router = express.Router();
const { get,update,del,add,search } = require("../service/usersService.js")


router.post('/getUsers', async function (req, res, next) {
  const parameter = req.query;
  const data = await get(parameter);
  res.send(data);
});

router.post('/updateUsers', async function (req, res, next) {
  const parameter = req.body;
  const {_id} = req.body;
  const data = await update(_id,parameter);
  res.send(data);
});

router.post('/deleteUsers', async function (req, res, next) {
  const _id = req.body;
  const data = await del(_id);
  res.send(data);
});

router.post('/addUser', async function (req, res, next) {
  const {parameter}= req.body;
  console.log(parameter);
  
  const data = await add(parameter);
  res.send(data);
});

router.post('/searchUser', async function (req, res, next) {
  const parameter = req.body;
  const data = await search(parameter);
  res.send(data);
});
module.exports = router;
